package jsp;
import static org.junit.Assert.*;
import com.meterware.httpunit.*;
import junit.framework.TestCase;
import static org.junit.Assert.*;
/** @author Alberto Magni*/
public class WrongPasswordLogin extends TestCase
{
    public void testWrongPassword() throws Exception 
    {
        EMailSendingTest em= new EMailSendingTest();
        UserAuthorizationTest uat=new UserAuthorizationTest();
        HttpUnitOptions.setScriptingEnabled(false);
        //setup
        WebResponse response =uat.userRegistration("Alberto Magni","alberto","goofy");
        assertEquals("Welcome", response.getTitle());
        System.out.println("alberto entered in: " +response.getTitle());
        String url="http://localhost:8084/Jerry/";
        WebConversation conversation= new WebConversation();
        response = uat.getAdministratorPage(conversation,url);
        WebForm usersform= response.getForms()[2];
        usersform.setParameter("enable", "alberto");
        response=usersform.submit();
        assertEquals("Administrator Configuration Page", response.getTitle());
        System.out.println("admin entered in: " +response.getTitle());
        //logout
        WebForm logoutbuttonform = response.getForms()[11];
        logoutbuttonform.getButtons()[0].click();
        response=conversation.getCurrentPage();
        assertEquals("Welcome", response.getTitle());
        System.out.println("admin entered in: " +response.getTitle());
        System.out.println("admin has logged out");
        response=em.login(url,new WebConversation(),"alberto","wrongpassword");
        assertEquals("Error", response.getTitle());
        System.out.println("An error occoured");
    }
}